package edu.scut.autoProcessor.dao;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.session.SqlSession;

public class PEDao extends AbstractDao{

	private static final Log log = LogFactory.getLog(PEDao.class);
	
	public static boolean validate(String userName, String passwd){
		SqlSession sqlSession = factory.openSession();
		
		try{
			Map<String, String> parameters = new HashMap<String, String>();
			parameters.put("name", userName);
			parameters.put("passwd", passwd);
			
			int isValid = (Integer) sqlSession.selectOne("alertProcessor.peMapper.validatePE", parameters);
			
			return isValid == 0 ? false : true;
		}catch(Exception e){
			log.warn(e.getMessage());
			e.printStackTrace();
			return false;
		}finally{
			sqlSession.close();
		}
	}
}
